<template>
  <a-breadcrumb class="breadcrumb">
    <!--    <a-breadcrumb-item v-for="(item) in breadList" :key="item.name">-->
    <!--      <router-link-->
    <!--        v-if="item.name != name && index != 1"-->
    <!--        :to="{ path: item.path === '' ? '/' : item.path }"-->
    <!--      >{{ item.meta.title }}</router-link>-->
    <!--      <span v-else>{{ item.meta.title }}</span>-->
    <!--    </a-breadcrumb-item>-->
    <a-breadcrumb-item>
      {{ name }}
    </a-breadcrumb-item>
  </a-breadcrumb>
</template>

<script>
export default {
  data () {
    return {
      name: '',
      breadList: []
    }
  },
  created () {
    this.getBreadcrumb()
  },
  mounted () {
  },
  methods: {
    getBreadcrumb () {
      this.breadList = []
      // this.breadList.push({name: 'index', path: '/dashboard/', meta: {title: '首页'}})
      this.name = this.$route.name
       this.$route.matched.forEach(item => {
        this.breadList.push(item)
      })
      // this.breadList[0] = this.$route.matched[this.$route.matched.length - 1]
      this.name = this.breadList[this.$route.matched.length - 1].meta.title
    }
  },
  watch: {
    $route () {
      this.getBreadcrumb()
    }
  }
}
</script>

<style scoped>
</style>
